<?php

namespace GanYiInfo\Card;

use GanYiInfo\Contracts\ArrayAble;
use GanYiInfo\Utils\Str;

class IdCard implements CardInterface, ArrayAble
{
    private $cardNo;

    private $name;

    public function __construct($cardNo, $name)
    {
        $this->cardNo = $cardNo;
        $this->name = $name;
    }

    /**
     * @throws \Exception
     */
    public function requireParameters()
    {
        if (Str::checkEmpty($this->cardNo) || Str::checkEmpty($this->name)) {
            throw new \Exception("IDCard missing require parameter.");
        }
    }

    /**
     * @return array
     */
    public function toArray()
    {
        return ["cardNo" => $this->cardNo, "name" => $this->name];
    }
}